package application;

import java.io.IOException;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;

import dao.DataLoader;
import dao.MockDAO;

public class Factory {

	static private MyLogger logger;

	public static DataLoader getDAO() {
		return new MockDAO();
	}

	public static MyLogger getLogger() {
		if (logger == null) {
			// logger = new MyLogger("Lunchy:");
			logger = (MyLogger) MyLogger.getLogger("Lunchy");
			try {
				logger.addAppender(new FileAppender(new PatternLayout(
				        "%d{dd.MM.yyyy HH:mm:ss} %p [%t] %c - %m%n"),
				        "lunchy.log"));
				logger.setLevel(Level.ALL);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}

		return logger;
	}
}